x86/amd: Use newer SSBD mechanisms if they exist
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 15 Oct 2021 09:15:14 +0000 (11:15 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 15 Oct 2021 09:15:14 +0000 (11:15 +0200)
commite0a8ffd498fb4c13bae0c80b0035dee4a34d3bb2
tree88828cab66a3988bf9332aba71283ade76e7499e
parent15734a72d7d38e9f8fd6a1a0bbb2a493a53d8dce
x86/amd: Use newer SSBD mechanisms if they exist

The opencoded legacy Memory Disambiguation logic in init_amd() neglected
Fam19h for the Zen3 microarchitecture.  Further more, all Zen2 based system
have the architectural MSR_SPEC_CTRL and the SSBD bit within it, so shouldn't
be using MSR_AMD64_LS_CFG.

Implement the algorithm given in AMD's SSBD whitepaper, and leave a
printk_once() behind in the case that no controls can be found.

This now means that a user explicitly choosing `spec-ctrl=ssbd` will properly
turn off Memory Disambiguation on Fam19h/Zen3 systems.

This still remains a single system-wide setting (for now), and is not context
switched between vCPUs.  As such, it doesn't interact with Intel's use of
MSR_SPEC_CTRL and default_xen_spec_ctrl (yet).

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
master commit: 2a4e6c4e4bea2e0bb720418c331ee28ff9c7632e
master date: 2021-09-08 14:16:19 +0100
xen/arch/x86/cpu/amd.c
xen/arch/x86/cpu/cpu.h
xen/arch/x86/cpu/hygon.c
xen/arch/x86/spec_ctrl.c